/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SLE_SEEK_H
#define SLE_SEEK_H

#include <iostream>
#include <memory>
#include "sle_seek_config.h"
#include "sle_device_config.h"
#include "sle_common_config.h"
#include "sle_error_code.h"

namespace OHOS {
namespace NearLink {
namespace SleStandard {
class SleSeekCallback {
public:
    /**
     *   @brief   delete SleSeekCallback instance
     *
     */
    virtual ~SleSeekCallback() = default;

    /**
     *   @brief   virtual seek state change define
     *
     *   @param   [in] status - status
     *   @return  void
     */
    virtual void OnSeekStateChange(SleSeekState status) = 0;

    /**
     *   @brief   virtual seek state change define
     *
     *   @param   [in] result - seek result
     *   @return  void
     */
    virtual void OnSeekResult(SleSeekResult &result) = 0;
};

class SleSeek {
public:
    /**
     *   @brief   Get SleSeek instance
     * 
     *   @return SleSeek instance ptr
     */
    static SleSeek &GetDefaultSeek();

    /**
     *   @brief   Start seek sync
     *
     *   @param   [in] param - seek param
     *   @return  SleErrorCode
     */
    SleErrorCode StartSeek(const SleSeekParam &param);

    /**
     *   @brief   Stop seek sync
     *
     *   @return  SleErrorCode
     */
    SleErrorCode StopSeek();

    /**
     *  @brief  get deault seek param sync
     *
     *  @param  [out] seekConfig - seek param config
     *  @return SleErrorCode - operation result
     */
    SleErrorCode GetDefaultSeekParamConfig(SleSeekParam &seekConfig);

    /**
     *   @brief   Regist seek callback sync
     *
     *   @param   [in] callback - seek callback
     *   @return  SleErrorCode
     */
    SleErrorCode RegisterSeekCallback(std::shared_ptr<SleSeekCallback> callback);

    /**
     *   @brief   Unregist seek callback sync
     *
     *   @param   [in] callback - seek callback
     *   @return  SleErrorCode
     */
    SleErrorCode UnregisterSeekCallback(std::shared_ptr<SleSeekCallback> callback);

private:
    /**
     *   @brief A constructor used to create a <b>SleSeek</b> instance.
     */
    SleSeek();

    /**
     *   @brief A constructor used to delete a <b>SleSeek</b> instance.
     */
    ~SleSeek();

    class SleSeekImpl;
    std::unique_ptr<SleSeekImpl> pimpl_;
    static SleSeek seekInstance_;

    SLE_DISALLOW_COPY_AND_ASSIGN(SleSeek);
};
} // SleStandard
} // NearLink
} // OHOS

#endif // SLE_SEEK_H